<?php
/*
 * Created on 22.12.2005
 *
 */

/**
 * attributes:
 * 
 * id: id of html element to show (display = 'block')
 */
class ajax_showElementHandler
{
    
    var $name = null;
    var $effect = false;

    function startElement (& $sender, $attrs, $line)
    {
        if (empty($attrs['id']))
            $sender->appendCode('$out->write("alert(\'Attribute id is missing in tag ajax:showElement in line '.$line.'!\');");');
        else
            if (isset($attrs['effect']))
            {
                $this->effect = true;
                switch ($attrs['effect'])
                {
                    case "'fade'":
                        $sender->appendCode('$out->write("dojo.lfx.html.fadeShow(\'".'.$attrs['id'].'."\', ".'.
                                (isset($attrs['duration']) ? $attrs['duration'] : "'100'").'.", null, function () {");');
                        break;
                    case "'wipe'":
                        $sender->appendCode('$out->write("dojo.lfx.html.wipeIn(\'".'.$attrs['id'].'."\', ".'.
                                (isset($attrs['duration']) ? $attrs['duration'] : "'100'").'.", null, function () {");');
                        break;
                    default: 
                        $sender->appendCode('$out->write("dojo.byId('.$attrs['id'].').style.display = \'block\';");');
                        $this->effect = false;
                }
            }
            else
                $sender->appendCode('$out->write("dojo.byId('.$attrs['id'].').style.display = \'block\';");');
    }

    function endElement (& $sender)
    {
        if ($this->effect)
            $sender->appendCode('$out->write("}).play();");');
    }

}

?>